<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>index</title>

    <div th:include="../templates/common::html_header"></div>
</head>
<body>

<div class="layui-input-inline" style="margin-left: 100px;margin-top: 100px;">
    <div>
        <button class="layui-btn" id="console">控制台</button>
    </div>
    <div style="margin-top: 20px;">
        <img id="uploadImg" width="87px;" height="87px;" style="cursor: pointer"
             th:src="@{{path}/img/addimg.png(path=${application.basePath}) }"/>
    </div>
</div>

</body>
<script>
    layui.use(['layer', 'upload'], function () {
        var $ = layui.$
            , layer = layui.layer
            , upload = layui.upload

        $("#console").click(function () {
            location.href = basePath + '/p/console';
        });

        upload.render({
            elem: '#uploadImg'
            , url: basePath + '/upload'
            , data:
                {module: 'fms/user'}
            , accept: 'file'
            , ext: 'jpg|png'
            , done: function (res) {
                if (res.success) {
                    var src = res.result;
                    console.log(src);
                    $("#uploadImg").attr("src", src);
                    layer.msg("图片上传成功");
                } else {
                    layer.alert("图片上传失败! \n " + res.message);
                }
            }
            , error: function () {
                layer.alert("图片上传失败!");
            }
        });

    });
</script>
</html>